var  webpack=require('webpack');
var helper=require("./helper");
var path = require('path');
const ExtractTextPlugin = require("extract-text-webpack-plugin");
module.exports={
    devtool:"cheap-module-source-map",
    entry:[
        helper.root('app')
    ],
    output:{
        path:helper.root('./dist'),
        filename:'app.js',
        chunkFilename: '[name].[chunkhash:5].chunk.js',
    },
    module: {
        loaders: [{
            test: /\.(js|jsx)$/,
            loaders: ['babel']
        },{
            test: /\.less/,
            exclude: /node_modules/,
            loader: ExtractTextPlugin.extract('style', 'css!less')
        },
            {
                test: /\.sass/,
                exclude: /node_modules/,
                loader: ExtractTextPlugin.extract('style', 'css!sass')
            }, {
                test: /\.css$/,
                loader: ExtractTextPlugin.extract('style', 'css')
            },
            {
                test: /\.(gif|jpg|png|woff|svg|eot|ttf)\??.*$/,
                loader: 'url-loader?limit=50000&name=[path][name].[ext]'
            },
            {
                test: /\.(svg)$/i,
                loader: require.resolve('svg-sprite-loader'),
                include: [
                    require.resolve('antd-mobile').replace(/warn\.js$/, ''),  // 1. 属于 antd-mobile 内置 svg 文件
                    //path.resolve(__dirname, './svg/'),  // 2. 自己私人的 svg 存放目录
                ]
            }
        ]
    },
    plugins: [
        new ExtractTextPlugin("css/index.less"),
        new webpack.DllReferencePlugin({
            context: __dirname,
            manifest:require('./../manifest.json')
        }),
        new webpack.DefinePlugin({
            'process.env': {
                'NODE_ENV': JSON.stringify('production')
            }
        }),
        //去掉重复
        new webpack.optimize.DedupePlugin(),
        new webpack.optimize.UglifyJsPlugin({
            compress: {
                //warnings: false,
            }
        }),

    ],
    resolve: {
        extensions: ['','.web.js', '.js', '.json'],
    }

}
